import unittest
from utils import Method
from config.config import get_url
from utils.db import db
from utils.Tokens import headers
import allure
import pytest
from utils.Load import load_yaml_data
from utils.path_utils import path_utils
from pytest_assume.plugin import assume

# 加载yaml数据
test_data = load_yaml_data(path_utils.get_data_path("quanxianadd.yaml"))

@allure.feature("这是权限类")
class TestCase:
    # @allure.story("查询权限")
    # @pytest.mark.test
    # def test_select_01(self):
    #     url = get_url() + '/boss/pms/permission/list'
    #     json = {"permissionName": "1234"}
    #     loging = Method.get(url, headers=headers(), json_data=json)
    #     # 创建实例
    #     db_instance = db()
    #     mysql=db_instance.query("SELECT permission_name FROM pms_permission WHERE permission_name = '1234'")
    #     data = mysql
    #     result = data[0][0]
    #     assume(result in loging.text)
    #     print(loging.text)

    @allure.story("添加权限")
    @pytest.mark.parametrize("permissionName, permission, remark", test_data)
    def test_add_02(self, permissionName, permission, remark):
        url = get_url() + '/boss/pms/permission/add'
        json = {"navTabId": "qxgl", "callbackType": "closeCurrent", "forwardUrl": "", "permissionName": permissionName,
                "permission": permission, "remark": remark}
        list = Method.post(url, data=json, headers=headers())
        print(list.text)

    @allure.story("删除权限")
    def test_delete_03(self):
        url = get_url() + '/boss/pms/permission/delete'
        json = {"permissionId": "279"}
        delete = Method.post(url, data=json, headers=headers())
        print(delete.text)


if __name__ == '__main__':
    unittest.main()
